package com.autoplaza;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class Navegador2 extends Activity {

	public String URL_video;
	public WebView browser;
	public Button btnmenu;
	public String red;
	public ProgressBar uno;

	
	public void voidFinish(View v){
		finish();
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_navegador2);
		uno = (ProgressBar) findViewById(R.id.progressBar1);

		
		btnmenu = (Button) findViewById(R.id.btn_menu);
		btnmenu.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {

				Intent goManuLateral = new Intent(Navegador2.this, MenuLateral.class);
				goManuLateral.putExtra("clase","Navegador2");
				goManuLateral.putExtra("red","Twitter");
				startActivity(goManuLateral);

			}
		});
		
		int size = Utils.getScreenSize2(Navegador2.this);
		if( size == 1){
			RelativeLayout lin = (RelativeLayout) findViewById(R.id.linearLayout1);
			lin.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 30));
			RelativeLayout.LayoutParams params0 = new RelativeLayout.LayoutParams(25, 25);
			params0.addRule(RelativeLayout.CENTER_HORIZONTAL);
			params0.addRule(RelativeLayout.CENTER_VERTICAL);
			params0.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
			btnmenu.setLayoutParams(params0);
//			btnmenu.setLayoutParams(new LinearLayout.LayoutParams(30, 30));
		}		
		if( size == 2){
			RelativeLayout lin = (RelativeLayout) findViewById(R.id.linearLayout1);
			lin.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 60));	
			RelativeLayout.LayoutParams params0 = new RelativeLayout.LayoutParams(50, 50);
			params0.addRule(RelativeLayout.CENTER_HORIZONTAL);
			params0.addRule(RelativeLayout.CENTER_VERTICAL);
			params0.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
			btnmenu.setLayoutParams(params0);
//			btnmenu.setLayoutParams(new LinearLayout.LayoutParams(45, 45));

		}		
		if( size == 3){
			RelativeLayout lin = (RelativeLayout) findViewById(R.id.linearLayout1);
			lin.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 80));
			RelativeLayout.LayoutParams params0 = new RelativeLayout.LayoutParams(70, 70);
			params0.addRule(RelativeLayout.CENTER_HORIZONTAL);
			params0.addRule(RelativeLayout.CENTER_VERTICAL);
			params0.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
			btnmenu.setLayoutParams(params0);
//			btnmenu.setLayoutParams(new LinearLayout.LayoutParams(80, 80));

		}
		
		Bundle extras = getIntent().getExtras();
		if (extras!=null){
						
			URL_video = extras.getString("url");
			red = extras.getString("red");
			TextView texto = (TextView) findViewById(R.id.textView2);
			texto.setText(""+red);
			
			Log.i("URL", ""+URL_video);
			browser = (WebView) findViewById(R.id.web_browser);
			
			browser.getSettings().setJavaScriptEnabled(true);
			browser.getSettings().setPluginsEnabled(true);
			browser.setWebViewClient(new WebViewClient() {
				@Override
				public boolean shouldOverrideUrlLoading(WebView view, String url) {
					view.loadUrl(url);
					return true;
				}
				
				@Override
				public void onPageFinished(WebView view, String url) {
					uno.setVisibility(View.GONE);
					
				}
			});
			browser.loadUrl(URL_video);
			
			
		    			
		}
		

		
	}

	

}
